from drf_spectacular.extensions import OpenApiAuthenticationExtension


class CustomJWTAuthenticationExtension(OpenApiAuthenticationExtension):
    target_class = 'auth_app.authentication.CustomJWTAuthentication'  # Full import path of the class
    name = 'Bearer'  # 使用与settings.py中一致的名称

    def get_security_definition(self, auto_schema):
        return {
            'type': 'http',
            'scheme': 'bearer',
            'bearerFormat': 'JWT',
            'description': 'JWT Token认证，格式: Bearer <token>'
        }